package cn.xwj.mongoDBtest;

import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;

/**
 * Created by thinkjoy on 2017/6/16.
 */
public class AppCollectionDelete {

    public static void main(String[] args){
        try {
            MongoDatabase mongoDatabase=MongoDBCon.MongoDBConInstence();
            MongoCollection<Document> collection=mongoDatabase.getCollection("thinkjoy");
           //删除文档
           collection.deleteOne(new Document("da","鳄鱼"));
//            查看结果
            FindIterable<Document>findIterable=collection.find();
            MongoCursor<Document>mongoCursor=findIterable.iterator();
            while (mongoCursor.hasNext()){
                System.out.println(mongoCursor.next());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
